<?php
$id=$_REQUEST["id"];
session_start();
$conn=new mysqli("localhost","root","123456","htmlkeshe");
$conn->query("set names utf8");

$picurl="./resource/img/userhead/user".$id.".jpg";//文件夹位置
if(is_uploaded_file($_FILES['uppicture']['tmp_name'])){
//    echo 1;
    unlink($picurl);//删除原图片
    if(move_uploaded_file($_FILES['uppicture']['tmp_name'],$picurl)){
        //图片上传成功
    }
}

$name=$_POST['name'];
$password=MD5($_POST['password']);
//echo $password;
$email=$_POST['email'];
$phone=$_POST['phone'];
$sql1="UPDATE user SET name='".$name."' WHERE id=".$id.";";
$result1=$conn->query($sql1) or die(mysqli_error($conn));
if ($password != "d41d8cd98f00b204e9800998ecf8427e"){
    $sql2="UPDATE user SET password='".$password."' WHERE id=".$id.";";
    $result2=$conn->query($sql2) or die(mysqli_error($conn));
}
$sql3="UPDATE user SET email='".$email."' WHERE id=".$id.";";
$result3=$conn->query($sql3) or die(mysqli_error($conn));
$sql4="UPDATE user SET phone='".$phone."' WHERE id=".$id.";";
$result4=$conn->query($sql4) or die(mysqli_error($conn));

$_SESSION['name']=$name;
$_SESSION['email']=$email;
$_SESSION['phone']=$phone;
$_SESSION['head']=$picurl;
header("location:Personal.php");
$conn->close();
